package com.rrd.mex.dw.mr.babel.parser;

import com.rrd.mex.dw.utils.DateUtil;
import com.ucredit.babel.common.model.BaseModel;
import com.ucredit.babel.common.model.RecordType;
import com.ucredit.babel.common.model.hfq.UploadBaseData;
import com.ucredit.babel.common.model.hfq.gps.UploadGpsData;
import com.ucredit.babel.common.model.hfq.gps.UploadGpsRecord;
import com.ucredit.babel.common.model.hfq.sms.UploadSmsDetail;
import com.ucredit.babel.common.model.hfq.sms.UploadSmsReportData;
import com.ucredit.babel.common.model.hfq.sms.UploadSmsReportRecord;
import com.ucredit.babel.common.model.mexico.BlackListCheckRecord;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.util.Date;
import java.util.List;

public class BlackListCheckRecordParse extends ParseBase{
    private Text val = new Text();
    private Text key = new Text();
    @Override
    public boolean parseJob(Mapper.Context context, BaseModel<?> model, String successful) throws IOException, InterruptedException {
        BlackListCheckRecord obj = (BlackListCheckRecord) model;
        StringBuilder sb = getBaseInfo(obj, successful,1);
        sb.append(obj.getMessage() == null ? "" : obj.getMessage()).append(CRT001);
        sb.append(obj.getCode() == null ? "" : obj.getCode()).append(CRT001);
        sb.append(obj.getTransactionId()==null?"":obj.getTransactionId()).append(CRT001);
        sb.append(obj.getPricingStrategy()==null?"":obj.getPricingStrategy()).append(CRT001);
        sb.append(obj.getExtra()==null?"":obj.getExtra()).append(CRT001);
        sb.append(obj.getHit()==null?"":obj.getHit()).append(CRT001);

        key.set(getKey());
        val.set(sb.toString().replace("\n", " ").replace("\r", " "));
        context.write(key, val);
        return true;
    }

    @Override
    public String getTableName() {
        return "kafka_babel_black_list_check_record_inc";
    }

    @Override
    public String getType() {
        return RecordType.BLACK_LIST_CHECK_RECORD.toString();
    }

    @Override
    public String getComment() {
        return "黑名单检测";
    }

    @Override
    public BaseModel getModel() {
        return new BlackListCheckRecord();
    }


}
